﻿using ET.Monitor.DAL;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ET.Monitor.Model
{
    public class ReportModel
    {
        #region 操作票

        int count = 10;
        int pageIndex = 1;
        string type = "0";
        string state = "0";
        string id = "";
        ReportDAL dal = new ReportDAL();

        DateTime st = new DateTime();
        DateTime et = new DateTime();

        int formId = 0;
        public ReportModel()
        {
        }
        public ReportModel(int id)
        {
            formId = id;
        }
        public ReportModel(string id, DateTime st)
        {
            this.st = st;
            this.id = id;
        }
        public ReportModel(string id, DateTime st, DateTime et)
        {
            this.et = et;
            this.st = st;
            this.id = id;
        }
        string filename = "";
        string fileType = "";
        byte[] file = null;
        public ReportModel(string stationId,string name, DateTime time, int filetype, string type, byte[] file)
        {
            id = stationId;
            filename = name;
            st = time;
            count = filetype;
            fileType = type;
            this.file = file;
        }

        public ReportModel(int count, int pageIndex, string type, string state, string id, DateTime st, DateTime et)
        {
            this.count = count;
            this.pageIndex = pageIndex;
            this.type = type;
            this.state = state;
            this.id = id;
            this.et = et;
            this.st = st;
        }
        #endregion

        #region 获取操作票数量
        int totalCount;

        public int TotalCount
        {
            get
            {
                return dal.GetTotalCount(type, state, id);
            }

            set
            {
                totalCount = value;
            }
        }

        #endregion

        #region 操作票分页
        DataTable dtForm;
        public DataTable DtForm
        {
            get
            {
                return dal.GetForm(count, pageIndex, type, state, id, st, et);
            }

            set
            {
                dtForm = value;
            }
        }
        #endregion

        string formConnect = "";
        int formType = 0;
        DateTime time = new DateTime();
        public ReportModel(string stationId, int formType, string connect, DateTime time)
        {
            id = stationId;
            this.formType = formType;
            formConnect = connect;
            this.time = time;
        }

        public ReportModel(int id, string connect)
        {
            formId = id;
            formConnect = connect;
        }

        #region 工作票录入
        bool blForm;

        public bool BlForm
        {
            get
            {
                return dal.AddOperation(id, formType, formConnect, time);
            }

            set
            {
                blForm = value;
            }
        }
        #endregion

        #region 获取某张工作票
        object objForm;
        public object ObjForm
        {
            get
            {
                return dal.GetOpeation(formId);
            }

            set
            {
                objForm = value;
            }
        }
        #endregion

        #region 编辑某张工作票
        bool editForm;
        public bool EditForm
        {
            get
            {
                return dal.UpdateOpeation(formId, formConnect);
            }

            set
            {
                editForm = value;
            }
        }
        #endregion

        #region 电量报表
        List<double[]> elecReport;
        public List<double[]> ElecReport
        {
            get
            {
                return dal.GetElecHisVal(id, st);
            }

            set
            {
                elecReport = value;
            }
        }
        #endregion

        #region 逆变器报表
        List<double[]> inverterReport;
        public List<double[]> InverterReport
        {
            get
            {
                return dal.GetInverterHisVal(id, st, et);
            }

            set
            {
                inverterReport = value;
            }
        }
        #endregion

        #region 文件上传
        bool upFile;

        public bool UpFile
        {
            get
            {
                return dal.UpLoaFile(id,filename, st, count, fileType, file);
            }
            set
            {
                upFile = value;
            }
        }
        #endregion

        #region 文件下载
        DataTable dtFile;

        public DataTable DtFile
        {
            get
            {
                return dal.GetFile(formId);
            }

            set
            {
                dtFile = value;
            }
        }
        bool _file;
        public bool DelFile
        {
            get
            {
                return dal.DeleteFile(formId);
            }
            set { _file = value; }
            
        }

        public DataTable DtSearchFile
        {
            get
            {
                return dal.SearchFile(id, st,et);
            }

            set
            {
                dtFile = value;
            }
        }
        

        #endregion

        #region 文件上传 类型
        DataTable dtFileType;

        public DataTable DtFileType
        {
            get
            {
                return dal.GetFileType();
            }

            set
            {
                dtFileType = value;
            }
        }
        #endregion
    }
}
